/* GUI CONVERTED from rqpm.p (converter v1.76) Tue Oct 30 12:36:14 2001 */
/* rqpm.p     - REQUISITION CONTROL FILE                                      */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.4.1.4 $                                                           */
/* Revision: 8.5    LAST MODIFIED: 04/22/97     By: *J1Q2* B. Gates           */
/* REVISION: 8.6E   LAST MODIFIED: 02/23/98     BY: *L007* A. Rahane          */
/* REVISION: 8.6E   LAST MODIFIED: 05/09/98     BY: *L00Y* Jeff Wootton       */
/* REVISION: 8.6E   LAST MODIFIED: 06/11/98     BY: *L040* Brenda Milton      */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane     */
/* REVISION: 9.1    LAST MODIFIED: 08/09/00     BY: *M0QW* Falguni Dalal      */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00     BY: *N0KP* myb                */
/* $Revision: 1.4.1.4 $    BY: Murali Ayyagari       DATE: 10/30/01  ECO: *N15H*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/
/*V8:ConvertMode=Maintenance                                                  */

{mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rqpm_p_2 "Using GRS"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

{rqconst.i}
{gpfieldv.i}

/* define shared variable using_grs    as logical no-undo        **M0QW*/
define shared variable using_grs    like mfc_logical no-undo
   label {&rqpm_p_2}.

define variable old_using_grs       as logical no-undo.

define variable email_opt_valid as logical no-undo.
define variable oot_rtg_valid as logical no-undo.

define variable null1 like exr_rate no-undo.
define variable null2 like exr_rate2 no-undo.
define variable null_ex_ratetype like exr_ratetype no-undo.
define variable mc-error-number like msg_nbr no-undo.

define variable c-mfclabel like mfc_label no-undo.
c-mfclabel = getTermLabel('GRS_INSTALLED',24).

/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
using_grs           colon 35
   rqf_pre             colon 35
   rqf_nbr             colon 35
   rqf_appr_curr       colon 35
   rqf_diraprs_req     colon 35
   rqf_horaprs_req     colon 35
   rqf_vrtaprs_req     colon 35
   rqf_use_tolpct      colon 35
   rqf_tol_pct         colon 60
   rqf_use_tolval      colon 35
   rqf_tol_val         colon 60
   rqf_ln_fmt          colon 35
   email_opt_entry     colon 35
   email_opt_desc      no-label
   oot_rtg_entry       colon 35
   oot_rtg_desc        no-label
   rqf_hcmmts          colon 35
   rqf_lcmmts          colon 35
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

repeat:
/*GUI*/ if global-beam-me-up then undo, leave.

   /*CREATE CONTROL FILE RECORD*/
   {gprun.i ""rqpma.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


   old_using_grs = using_grs.

   find first rqf_ctrl exclusive-lock.

   view frame a.

   {gplngn2a.i
      &file=""rqf_ctrl""
      &field=""rqf_email_opt""
      &code=rqf_email_opt
      &mnemonic=email_opt_entry
      &label=email_opt_desc}

   {gplngn2a.i
      &file=""rqf_ctrl""
      &field=""rqf_oot_rtg""
      &code=rqf_oot_rtg
      &mnemonic=oot_rtg_entry
      &label=oot_rtg_desc}

   display
      using_grs
      rqf_pre
      rqf_nbr
      rqf_appr_curr
      rqf_diraprs_req
      rqf_horaprs_req
      rqf_vrtaprs_req
      rqf_use_tolpct
      rqf_tol_pct
      rqf_use_tolval
      rqf_tol_val
      rqf_ln_fmt
      email_opt_entry
      email_opt_desc
      oot_rtg_entry
      oot_rtg_desc
      rqf_hcmmts
      rqf_lcmmts
   with frame a.

   do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.

      set
         using_grs
         rqf_pre
         rqf_nbr
         rqf_appr_curr
         rqf_diraprs_req
         rqf_horaprs_req
         rqf_vrtaprs_req
         rqf_use_tolpct
         rqf_tol_pct
         rqf_use_tolval
         rqf_tol_val
         rqf_ln_fmt
         email_opt_entry
         oot_rtg_entry
         rqf_hcmmts
         rqf_lcmmts
      with frame a.

      {gpfield.i &field_name = '"rqf_nbr"'}

      if length(rqf_pre) + length(string(rqf_nbr))
         > length(field_format) then do:
         {pxmsg.i &MSGNUM=312 &ERRORLEVEL=3 &MSGARG1=length(field_format)}
         /*PREFIX AND NUMBER COMBINED CANNOT EXCEED # CHARACTERS*/
         next-prompt rqf_nbr with frame a.
         undo, retry.
      end.

      if rqf_appr_curr = "" then do:
         {pxmsg.i &MSGNUM=1260 &ERRORLEVEL=3}
         /*BLANK CURRENCY NOT ALLOWED*/
         next-prompt rqf_appr_curr with frame a.
         undo, retry.
      end.

      if rqf_appr_curr <> base_curr then do:

         /* VALIDATE CURRENCY */
         {gprunp.i "mcpl" "p" "mc-chk-valid-curr"
            "(input rqf_appr_curr,
              output mc-error-number)"}
         if mc-error-number = 0 then do:
            /* GET EXCHANGE RATE TO BASE CURRENCY */
            {gprunp.i "mcpl" "p" "mc-get-ex-rate"
               "(input rqf_appr_curr,
                 input base_curr,
                 input null_ex_ratetype,
                 input today,
                 output null1,
                 output null2,
                 output mc-error-number)"}
         end.  /* if mc-error-number = 0 */
         if mc-error-number <> 0 then do:
            {pxmsg.i &MSGNUM=mc-error-number &ERRORLEVEL=3}
            next-prompt rqf_appr_curr with frame a.
            undo, retry.
         end.
      end.  /* if rqf_appr_curr <> base_curr */

      {gplngv.i
         &file=""rqf_ctrl""
         &field=""rqf_email_opt""
         &mnemonic=email_opt_entry
         &isvalid=email_opt_valid}

      if not email_opt_valid then do:
         {pxmsg.i &MSGNUM=1860 &ERRORLEVEL=3} /* INVALID E-MAIL OPTION */
         next-prompt email_opt_entry with frame a.
         undo, retry.
      end.

      {gplngv.i
         &file=""rqf_ctrl""
         &field=""rqf_oot_rtg""
         &mnemonic=oot_rtg_entry
         &isvalid=oot_rtg_valid}

      if not oot_rtg_valid then do:
         {pxmsg.i &MSGNUM=1860 &ERRORLEVEL=3}
         /* INVALID OUT OF TOLERENCE ROUTING OPTION */
         next-prompt oot_rtg_entry with frame a.
         undo, retry.
      end.

      {gplnga2n.i
         &file=""rqf_ctrl""
         &field=""rqf_email_opt""
         &code=rqf_email_opt
         &mnemonic=email_opt_entry
         &label=email_opt_desc}

      {gplnga2n.i
         &file=""rqf_ctrl""
         &field=""rqf_oot_rtg""
         &code=rqf_oot_rtg
         &mnemonic=oot_rtg_entry
         &label=oot_rtg_desc}

      display
         email_opt_desc
         oot_rtg_desc
      with frame a.

      /* HAS GRS FLAG CHANGED? */
      if using_grs <> old_using_grs then do:

         /* FIND CURRENT MASTER CONTROL RECORD */
         find mfc_ctrl where
            mfc_field = "grs_installed"
         exclusive-lock no-error.

         /* WANT TO ACTIVATE GRS? */
         if using_grs then do:

            /* VERIFY MASTER CONTROL RECORD FLAG IS TURNED ON */
            if available (mfc_ctrl) then do:
               if mfc_logical = no then
               set
                  mfc_logical = yes.
            end.
            else do:  /* if not available (mfc_ctrl) */

               /* CREATE MASTER CONTROL RECORD */
               create mfc_ctrl.
               assign
                  mfc_field = "grs_installed"
                  mfc_seq = 1
                  mfc_module = "req"
                  mfc_type = "l"             /* logical */
                  mfc_label = c-mfclabel
                  mfc_logical = yes.
            end.  /* if not available (mfc_ctrl) */

         end.      /* WANT TO ACTIVATE GRS?   */
         else do:  /* WANT TO DEACTIVATE GRS? */

            /* MAKE SURE CONTROL RECORD IS TURNED OFF */
            if available (mfc_ctrl) then do:
               delete mfc_ctrl.
            end.
         end.  /* WANT TO DEACTIVATE GRS? */

      end.  /* if using_grs <> old_using_grs */

   end.
/*GUI*/ if global-beam-me-up then undo, leave.
  /* do on error undo, retry: */
end.
/*GUI*/ if global-beam-me-up then undo, leave.
  /* repeat: */

status input.
